<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiSearchModelCollectionSelectTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_search_model_collection_select';

    /**
     * Run the migrations.
     * @table qii_search_model_collection_select
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->unsignedInteger('data_id')->default('0');
            $table->string('field', 30)->default('');
            $table->unsignedBigInteger('field_crc32')->default('0');
            $table->unsignedInteger('value')->default('0');

            $table->index(["data_id", "field_crc32"], 'data_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
